<template>
  <div class="app-container">
    <div class="OrderSummaryContainer">
      <div class="search">
        <img class="searchImg" src="./image/search.png" alt="" />
        <span class="searchText">筛选查询</span>
      </div>
      <!-- 查询表单 -->
      <div class="form">
        <el-form :inline="true" :model="formInline" class="demo-form-inline">
          <el-form-item>
            <el-input clearable class="w-50 m-2 inputBase" size="large" placeholder="请输入指令" />
          </el-form-item>

          <el-form-item>
            <el-select v-model="type" filterable placeholder="货号" class="inputBase">
              <el-option v-for="item in types" :key="item.value" :label="item.label" :value="item.value" />
            </el-select>
          </el-form-item>

          <el-form-item>
            <el-select v-model="type" filterable placeholder="季度" class="inputBase">
              <el-option v-for="item in types" :key="item.value" :label="item.label" :value="item.value" />
            </el-select>
          </el-form-item>

          <el-form-item>
            <el-select v-model="type" filterable placeholder="样品类型" class="inputBase">
              <el-option v-for="item in types" :key="item.value" :label="item.label" :value="item.value" />
            </el-select>
          </el-form-item>

          <el-form-item>
            <el-select v-model="type" filterable placeholder="厂商" class="inputBase">
              <el-option v-for="item in types" :key="item.value" :label="item.label" :value="item.value" />
            </el-select>
          </el-form-item>

          <el-form-item>
            <el-select v-model="type" filterable placeholder="类型" class="inputBase">
              <el-option v-for="item in types" :key="item.value" :label="item.label" :value="item.value" />
            </el-select>
          </el-form-item>

          <el-form-item label="下单日期" class="date">
            <el-date-picker v-model="deliveryTime" type="daterange" range-separator="-" start-placeholder="2023-06-07" end-placeholder="2023-06-07" />
          </el-form-item>

          <el-form-item label="指令交期" class="date">
            <el-date-picker v-model="deliveryTime" type="daterange" range-separator="-" start-placeholder="2023-06-07" end-placeholder="2023-06-07" />
          </el-form-item>

          <el-form-item>
            <el-input clearable class="w-50 m-2 inputBase" size="large" placeholder="请输入订单号" />
          </el-form-item>

          <el-form-item>
            <el-input clearable class="w-50 m-2 inputBase" size="large" placeholder="请输入材质" />
          </el-form-item>

          <el-form-item>
            <el-input clearable class="w-50 m-2 inputBase" size="large" placeholder="请输入颜色" />
          </el-form-item>

          <el-form-item label="订购日期" class="date">
            <el-date-picker v-model="deliveryTime" type="daterange" range-separator="-" start-placeholder="2023-06-07" end-placeholder="2023-06-07" />
          </el-form-item>

          <el-form-item label="需求日期" class="date">
            <el-date-picker v-model="deliveryTime" type="daterange" range-separator="-" start-placeholder="2023-06-07" end-placeholder="2023-06-07" />
          </el-form-item>

          <el-form-item>
            <el-select v-model="type" filterable placeholder="采购员" class="inputBase">
              <el-option v-for="item in types" :key="item.value" :label="item.label" :value="item.value" />
            </el-select>
          </el-form-item>

          <el-form-item>
            <el-button type="primary" size="default" @click="">查询</el-button>
            <el-button type="primary" size="default" @click="">清空</el-button>
          </el-form-item>
        </el-form>
      </div>

      <div class="main">
        <!-- 指令明细 -->
        <el-card class="MainNewly" :body-style="{ padding: '0px' }">
          <el-card class="cardOne" :body-style="{ padding: '0px' }">
            <!-- 标题 -->
            <template #header>
              <div class="cardOne-header">
                <span>指令明细</span>
              </div>
            </template>
            <!-- 指令明细表格 -->
            <div class="table2">
              <el-table border class="customer-table" :data="tableData" style="width: 100%" height="600">
                <el-table-column show-overflow-tooltip align="center" prop="date" label="指令" width="92" />
                <el-table-column show-overflow-tooltip align="center" prop="address" label="数量" width="54" />
                <el-table-column show-overflow-tooltip align="center" prop="name" label="状态" width="54" />
                <el-table-column show-overflow-tooltip align="center" prop="name" label="状态" width="54" />
                <el-table-column show-overflow-tooltip align="center" prop="name" label="生产" width="72" />
              </el-table>
            </div>
          </el-card>
        </el-card>

        <!-- 材料明细 -->
        <el-card class="rightCard" :body-style="{ padding: '0px' }">
          <el-card class="rightCardOne" :body-style="{ padding: '0px' }">
            <!-- 标题 -->
            <template #header>
              <div class="rightCardOne-header">
                <span>生产进度</span>
              </div>
            </template>
            <!-- 入库单据明细表格 -->
            <div class="scheduleTable">
              <el-table border class="customer-table" :data="scheduleTableData" style="width: 100%">
                <el-table-column show-overflow-tooltip width="81" align="center" prop="date" label="裁断欠数"> </el-table-column>
                <el-table-column show-overflow-tooltip width="81" align="center" prop="address" label="计划" />
                <el-table-column show-overflow-tooltip width="81" align="center" prop="name" label="实际" />
                <el-table-column show-overflow-tooltip width="81" align="center" prop="name" label="配套次数" />
                <el-table-column show-overflow-tooltip width="81" align="center" prop="name" label="计划" />
                <el-table-column show-overflow-tooltip width="81" align="center" prop="name" label="实际" />
                <el-table-column show-overflow-tooltip width="81" align="center" prop="name" label="针车欠数" />
                <el-table-column show-overflow-tooltip width="81" align="center" prop="name" label="计划" />
                <el-table-column show-overflow-tooltip width="81" align="center" prop="name" label="实际" />
                <el-table-column show-overflow-tooltip width="81" align="center" prop="name" label="大底欠数" />
                <el-table-column show-overflow-tooltip width="81" align="center" prop="name" label="计划" />
                <el-table-column show-overflow-tooltip width="81" align="center" prop="name" label="实际" />
                <el-table-column show-overflow-tooltip width="81" align="center" prop="name" label="成型欠数" />
                <el-table-column show-overflow-tooltip width="81" align="center" prop="name" label="计划" />
                <el-table-column show-overflow-tooltip width="81" align="center" prop="name" label="实际" />
              </el-table>
            </div>
          </el-card>
          <el-card class="rightCardTwo" :body-style="{ padding: '0px' }">
            <!-- 标题 -->
            <template #header>
              <div class="rightCardOne-header">
                <span>材料明细</span>
              </div>
            </template>
            <!-- 材料明细表格 -->
            <div class="materialTable">
              <el-table :data="materialTableData" :cell-style="cellStyle" :header-cell-style="headerStyle" height="380">
                <el-table-column show-overflow-tooltip align="center" prop="date" label="颜色"> </el-table-column>
                <el-table-column show-overflow-tooltip align="center" prop="address" label="材质" />
                <el-table-column show-overflow-tooltip align="center" prop="name" label="规格" />
                <el-table-column show-overflow-tooltip align="center" prop="name" label="单位" />
                <el-table-column show-overflow-tooltip align="center" prop="name" label="类型" />
                <el-table-column show-overflow-tooltip align="center" prop="name" label="订购单号" />
                <el-table-column show-overflow-tooltip align="center" prop="name" label="需求日期" />
                <el-table-column show-overflow-tooltip align="center" prop="name" label="订购日期" />
                <el-table-column show-overflow-tooltip align="center" prop="name" label="厂商" />
                <el-table-column show-overflow-tooltip align="center" prop="name" label="订购数量" />
                <el-table-column show-overflow-tooltip align="center" prop="name" label="入库数量" />
                <el-table-column show-overflow-tooltip align="center" prop="name" label="入库日期" />
                <el-table-column show-overflow-tooltip align="center" prop="name" label="采购员" />
                <el-table-column show-overflow-tooltip align="center" prop="name" label="备注" />
              </el-table>
            </div>
            <!-- 分页器 -->
            <div class="bottom">
              <span class="total">共{{ total }}项数据</span>
              <el-pagination
                v-model:current-page="currentPage"
                v-model:page-size="pageSize"
                :page-sizes="[10, 20, 30, 40]"
                layout="sizes, prev, pager, next, jumper"
                :total="total"
                @size-change="handleSizeChange"
                @current-change="handleCurrentChange"
              />
              <div>
                <el-button class="save" type="primary" size="default" @click="">保存</el-button>
                <el-button type="primary" size="default" @click="">打印</el-button>
              </div>
            </div>
          </el-card>
        </el-card>
      </div>
    </div>
  </div>
</template>
<script lang="ts">
import type { TableColumnCtx } from 'element-plus/es/components/table/src/table-column/defaults'
import { defineComponent, onMounted, reactive, ref } from 'vue'
import JMessage from '@/utils/JMessage'
export default defineComponent({
  name: 'ProductionDynamicQuery'
})
</script>
<script lang="ts" setup>
import { i18n, Jzhcn } from '@/i18n'
const formInline = reactive({
  user: '',
  region: ''
})
const type = ref('')
const types = [
  {
    value: 'Option1',
    label: 'Option1'
  },
  {
    value: 'Option2',
    label: 'Option2'
  },
  {
    value: 'Option3',
    label: 'Option3'
  },
  {
    value: 'Option4',
    label: 'Option4'
  },
  {
    value: 'Option5',
    label: 'Option5'
  }
]

const deliveryTime = ref('')
// 表格1数据
const tableData = [
  {
    date: '20230427',
    name: 'Tom',
    address: '12312'
  },
  {
    date: '2016-05-02',
    name: 'Tom',
    address: '12312'
  },
  {
    date: '2016-05-04',
    name: 'Tom',
    address: '12312'
  },
  {
    date: '2016-05-01',
    name: 'Tom',
    address: '12312'
  },
  {
    date: '2016-05-04',
    name: 'Tom',
    address: '12312'
  },
  {
    date: '2016-05-04',
    name: 'Tom',
    address: '12312'
  },
  {
    date: '2016-05-04',
    name: 'Tom',
    address: '12312'
  },
  {
    date: '2016-05-04',
    name: 'Tom',
    address: '12312'
  },
  {
    date: '2016-05-04',
    name: 'Tom',
    address: '12312'
  },
  {
    date: '2016-05-04',
    name: 'Tom',
    address: '12312'
  },
  {
    date: '2016-05-04',
    name: 'Tom',
    address: '12312'
  },
  {
    date: '2016-05-04',
    name: 'Tom',
    address: '12312'
  },
  {
    date: '2016-05-04',
    name: 'Tom',
    address: '12312'
  },
  {
    date: '2016-05-04',
    name: 'Tom',
    address: '12312'
  },

  {
    date: '2016-05-04',
    name: 'Tom',
    address: '12312'
  }
]
// 表格2数据
const scheduleTableData = [
  {
    date: '20230427',
    name: 'Tom',
    address: '12312'
  }
]
// 表格3数据
const materialTableData = [
  {
    date: '20230427',
    name: 'Tom',
    address: '12312'
  },
  {
    date: '20230427',
    name: 'Tom',
    address: '12312'
  },
  {
    date: '20230427',
    name: 'Tom',
    address: '12312'
  },
  {
    date: '20230427',
    name: 'Tom',
    address: '12312'
  },
  {
    date: '20230427',
    name: 'Tom',
    address: '12312'
  },
  {
    date: '20230427',
    name: 'Tom',
    address: '12312'
  },
  {
    date: '20230427',
    name: 'Tom',
    address: '12312'
  },
  {
    date: '20230427',
    name: 'Tom',
    address: '12312'
  },
  {
    date: '20230427',
    name: 'Tom',
    address: '12312'
  }
]
// 分页器
const currentPage = ref(1)
const pageSize = ref(10)
const total = ref(658)
const handleSizeChange = (val: number) => {
  console.log(`${val} items per page`)
}
const handleCurrentChange = (val: number) => {
  console.log(`current page: ${val}`)
}

// 修改表格标题样式
const headerStyle = ({ row, column, rowIndex, columnIndex }: any) => {
  console.log(columnIndex)
  if (columnIndex < 5) {
    return { 'background-color': '#FFF5EB', color: '#191919', border: 'none' }
  }
  if (columnIndex > 4 && columnIndex < 10) {
    return { 'background-color': '#F6F6F6', color: '#191919', border: 'none' }
  }
  if (columnIndex > 9 && columnIndex < 13) {
    return { 'background-color': '#FFF5EB', color: '#191919', border: 'none' }
  }
  if (columnIndex > 12) {
    return { 'background-color': '#F6F6F6', color: '#191919', border: 'none' }
  }
}
// 修改表格体样式
const cellStyle = ({ row, column, rowIndex, columnIndex }: { row: any; rowIndex: number; column: TableColumnCtx<any>; columnIndex: number }) => {
  if (columnIndex < 5) {
    return { 'background-color': '#FFF5EB', color: '#191919', border: 'none' }
  }
  if (columnIndex > 4 && columnIndex < 10) {
    return { 'background-color': '#F6F6F6', color: '#191919', border: 'none' }
  }
  if (columnIndex > 9 && columnIndex < 13) {
    return { 'background-color': '#FFF5EB', color: '#191919', border: 'none' }
  }
  if (columnIndex > 12) {
    return { 'background-color': '#F6F6F6', color: '#191919', border: 'none' }
  }
}
</script>

<style lang="less" scoped>
.OrderSummaryContainer {
  height: 100%;

  // 筛选查询行
  .search {
    height: 20px;
    line-height: 20px;
    display: flex;
    align-items: center;

    .searchImg {
      width: 20px;
      height: 20px;
    }

    .searchText {
      font-size: 14px;
      font-family: PingFangSC-Medium-, PingFangSC-Medium;
      color: #666666;
      margin-left: 8px;
    }
  }

  // 搜索行
  .form {
    .el-form {
      display: flex;
      align-items: center;
      flex-wrap: wrap;
    }

    .inputBase {
      width: 128px;
      height: 32px;
    }

    :deep(.el-range__icon) {
      position: absolute;
      right: 6px;
      color: #f89027 !important;
    }

    :deep(.el-range__close-icon) {
      position: absolute;
      left: 5px;
    }

    .date {
      width: 320px;
    }

    .el-form-item:last-child {
      margin-right: 0;
    }

    .el-form-item {
      margin: 0;
      margin-right: 15px;
      margin: 24px 15px 0px 0px;
    }

    .el-range__icon {
      display: none;
    }

    :deep(.el-range-input) {
      width: 110px;
    }

    :deep(.el-range-editor.el-input__wrapper) {
      padding: 0;
      padding-right: 10px;
    }

    :deep(.el-input__inner) {
      text-align: center;
    }

    .el-button {
      height: 23px;
      font-size: 14px;
    }
  }

  // 单选行
  .checkbox {
    display: flex;
    justify-content: right;
    align-items: center;
    .el-checkbox {
      margin-right: 15px;
    }

    :deep(.el-checkbox__input.is-checked + .el-checkbox__label) {
      color: black;
    }
  }

  // 底部
  .bottom {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 40px;

    .total {
      font-size: 14px;
      color: rgba(0, 0, 0, 0.6);
      font-family: PingFangSC-Regular-, PingFangSC-Regular;
    }

    :deep(.el-input__wrapper) {
      padding: 0;
    }

    :deep(.el-input__suffix) {
      transform: translateX(-9px);
    }

    :deep(.el-pagination .el-select .el-input) {
      width: 88px;
    }

    :deep(.number) {
      border: 1px solid #dcdcdc;
      margin-right: 8px;
      border-radius: 3px 3px 3px 3px;
    }

    :deep(.is-active.number) {
      background-color: #f89027 !important;
      color: white;
      border-radius: 3px 3px 3px 3px;
    }
  }

  .main {
    display: flex;
    justify-content: start;
    height: 670px;
    .el-card {
      box-shadow: none;
      margin-top: 13px;
      padding: 0 10px 0;
      border: none;

      // 卡片头部
      :deep(.el-card__header) {
        border-bottom: none;
        padding: 0;
        font-family: Segoe UI-Semibold, Segoe UI;
        font-weight: 600;
        font-size: 20px;
      }

      .card-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding-top: 14px;
      }

      .save {
        color: black;
        border: 1px solid #e7e7e7;
        background: #e7e7e7;
      }

      :deep(.el-card__body) {
        padding: 0px 10px 10px;
      }
    }

    .MainNewly {
      box-shadow: none;
      margin-right: 24px;

      .cardOne {
        border: none;
        width: 100%;

        .cardOne-header {
          padding: 0;
          padding-top: 0px;
        }
      }

      .table2 {
        margin: 12px 0px 5px;
        :deep(.el-table__header .cell) {
          color: #191919;
          font-size: 14px;
        }

        // 表格最上面边框
        :deep(.el-table--border .el-table__inner-wrapper::after) {
          // left: 0;
          position: relative;
        }

        // 表格最外边框
        :deep(.el-table--border, .el-table--group) {
          border: none;
        }

        // 头部边框
        :deep(.customer-table thead tr th.is-leaf) {
          border-right: none;
        }

        // 左边边框
        :deep(.customer-table thead tr th:nth-last-of-type(2)) {
          border-right: none;
        }

        // 取消左侧头部边框
        :deep(.el-table--border .el-table__inner-wrapper tr:first-child th:first-child) {
          border-left: none;
        }

        // 左侧体边框修改top
        :deep(.el-table__border-left-patch) {
          top: 40px;
          left: 0;
          width: 1px;
          height: 100%;
          z-index: 3;
          position: absolute;
          background-color: var(--el-table-border-color);
        }

        // 表格最外层边框-底部边框
        :deep(.el-table--border::after, .el-table--group::after) {
          width: 0;
        }

        :deep(.customer-table::before) {
          width: 0;
        }

        // 取消表格底部边框
        :deep(.el-table__inner-wrapper::before) {
          position: relative;
        }
      }
    }

    .rightCard {
      .rightCardOne {
        .scheduleTable {
          margin: 12px 0px 5px;
          :deep(.el-table__header .cell) {
            color: #191919;
            font-size: 14px;
          }

          // 表格最上面边框
          :deep(.el-table--border .el-table__inner-wrapper::after) {
            // left: 0;
            position: relative;
          }

          // 表格最外边框
          :deep(.el-table--border, .el-table--group) {
            border: none;
          }

          // 头部边框
          :deep(.customer-table thead tr th.is-leaf) {
            // border: 1px solid #EBEEF5;
            border-right: none;
          }

          // 左边边框
          :deep(.customer-table thead tr th:nth-last-of-type(2)) {
            border-right: none;
          }

          // 取消左侧头部边框
          :deep(.el-table--border .el-table__inner-wrapper tr:first-child th:first-child) {
            border-left: none;
          }

          // 左侧体边框修改top
          :deep(.el-table__border-left-patch) {
            top: 40px;
            left: 0;
            width: 1px;
            height: 100%;
            z-index: 3;
            position: absolute;
            background-color: var(--el-table-border-color);
          }

          // 表格最外层边框-底部边框
          :deep(.el-table--border::after, .el-table--group::after) {
            width: 0;
          }

          :deep(.customer-table::before) {
            width: 0;
          }

          // 取消表格底部边框
          :deep(.el-table__inner-wrapper::before) {
            position: relative;
          }

          // 改变颜色
          :deep(.el-table_2_column_6.is-center.is-leaf.el-table__cell .cell) {
            color: #f89027;
          }

          :deep(.el-table_2_column_9.is-center.is-leaf.el-table__cell .cell) {
            color: #f89027;
          }

          :deep(.el-table_2_column_12.is-center.is-leaf.el-table__cell .cell) {
            color: #f89027;
          }

          :deep(.el-table_2_column_15.is-center.is-leaf.el-table__cell .cell) {
            color: #f89027;
          }

          :deep(.el-table_2_column_18.is-center.is-leaf.el-table__cell .cell) {
            color: #f89027;
          }
        }
      }

      .rightCardTwo {
        .materialTable {
          margin-top: 10px;

          :deep(.el-table__inner-wrapper::before) {
            position: relative;
          }
        }
      }
    }
  }
}
</style>
